from django.db import models
from settingother.models import *
# Create your models here.

class TeacherBase(models.Model):
    SEX_CHOICES= ((True,'男'),(False,'女'))
    
    name = models.CharField(max_length=50,verbose_name='姓名')
    sex = models.BooleanField(choices=SEX_CHOICES,verbose_name='性别')
    birthday = models.DateField(verbose_name='出生日期')
    IDcard = models.CharField(max_length=18,verbose_name='身份证')
    nation = models.ForeignKey(verbose_name='民族',to=Nation,related_name='nations',on_delete=models.CASCADE)
    political_climate = models.ForeignKey(verbose_name='政治面貌',to=PoliticalClimate,related_name='political_climates',on_delete=models.CASCADE)
    address = models.CharField(max_length=200,verbose_name='家庭地址')

    class Meta:
        verbose_name = '教职工基本信息'
        verbose_name_plural = verbose_name

    def __str__(self):
        return '%s' %self.name

class TeacherSchool(models.Model):
    name = models.ForeignKey(verbose_name='姓名',to=TeacherBase,related_name='names',on_delete=models.CASCADE)
    school = models.ForeignKey(verbose_name='学校',to=School,related_name='schools',on_delete=models.CASCADE)
    grade = models.ForeignKey(verbose_name='年级',to=Grade,related_name='grades',on_delete=models.CASCADE,null=True,blank=True)
    class_bj = models.ForeignKey(verbose_name='班级',to=ClassBj,related_name='class_bjs',on_delete=models.CASCADE,null=True,blank=True)
    subject = models.ForeignKey(verbose_name='科目',to=Subject,related_name='subjects',on_delete=models.CASCADE,null=True,blank=True)
    address = models.CharField(max_length=200,verbose_name='现住地址')
    start_date = models.DateField(verbose_name='进入本校时间')
    end_date = models.DateField(verbose_name='离开本校时间',null=True,blank=True)

    class Meta:
        verbose_name = '教职工学校信息'
        verbose_name_plural = verbose_name

    def __str__(self):
        return '%s' %self.school

class TeacherFamily(models.Model):
    name = models.ForeignKey(verbose_name='姓名',to=TeacherBase,on_delete=models.CASCADE)
    fname = models.CharField(max_length=50,verbose_name='姓名')
    fIDcard = models.CharField(max_length=18,verbose_name='身份证')
    relationship = models.CharField(max_length=18,verbose_name='关系')
    fnation = models.ForeignKey(verbose_name='民族',to=Nation,on_delete=models.CASCADE)
    address = models.CharField(max_length=200,verbose_name='家庭地址')
    work = models.CharField(max_length=50,verbose_name='工作')
    workunit = models.CharField(max_length=50,verbose_name='工作单位')
    workaddress = models.CharField(max_length=50,verbose_name='工作地址')

    class Meta:
        verbose_name = '家庭成员信息'
        verbose_name_plural = verbose_name

    def __str__(self):
        return '%s' %self.fname

class TeacherExpend(models.Model):
    name = models.OneToOneField(TeacherBase,verbose_name='姓名',on_delete=models.CASCADE)
    recogntion_date = models.DateField(verbose_name='认定出生日期')
    participate_date = models.DateField(verbose_name='参工日期')
    hometown = models.CharField(max_length=150,verbose_name='籍贯')
    employment_type = models.CharField(max_length=10,verbose_name='在职类型')

    class Meta:
        verbose_name = '教职工拓展信息'
        verbose_name_plural = verbose_name

    def __str__(self):
        return '%s' %self.hometown